home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / unixlib / h / sigstate next >
Text File  |  1996-11-09  |  6KB  |  176 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/unixlib/h/RCS/sigstate,v $
  4.  * $Date: 1996/10/30 21:57:16 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: sigstate,v $
  10.  * Revision 1.1  1996/10/30 21:57:16  unixlib
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. /* This is an internal UnixLib header file for implementing the signal
  16.    handlers.  This functions cannot be used in a user program.  */
  17.  
  18. #ifndef    __UNIXLIB_SIGSTATE_H
  19. #define    __UNIXLIB_SIGSTATE_H 1
  20.  
  21. #ifndef __STDDEF_H
  22. #include <stddef.h>
  23. #endif
  24. #ifndef __SIGNAL_H
  25. #include <signal.h>
  26. #endif
  27. #ifndef __ERRNO_H
  28. #include <errno.h>
  29. #endif
  30.  
  31. /* Signal state for each thread.  */
  32.  
  33. struct unixlib_sigstate
  34.   {
  35.     /* The blocked signals for this process.  */
  36.     sigset_t blocked;
  37.     /* The pending signals for this process.  */
  38.     sigset_t pending;
  39.     /* The defined signal handlers for this process.  */
  40.     struct sigaction actions[NSIG];
  41.     struct sigaltstack signalstack;
  42.     struct
  43.       {
  44.     /* For each signal that may be pending, the
  45.        sigcode and error code to deliver it with.  */
  46.     int code, error;
  47.       } pending_data[NSIG];
  48.  
  49.     /* If `suspended' is set when this process gets a signal,
  50.        the signal thread sends an empty message to it.  */
  51.     int suspended;
  52.  
  53.     /* If 'currently_handling' is set, then the process is currently
  54.        executing a signal handler. Any raised signals will be pended and
  55.        executed after the current signal has finished executing.  */
  56.     int currently_handling;
  57.   };
  58.  
  59. /* Initialize the signal code.  */
  60. extern void __unixlib_sig_init (void);
  61.  
  62. /* Raise a signal as described by SIGNO, SIGCODE and SIGERROR, on the
  63.    process whose sigstate SS points to.  If SS is a null pointer, this
  64.    instead affects the calling process.  */
  65.  
  66. extern void __unixlib_raise_signal (struct unixlib_sigstate *ss,
  67.                 int signo, int sigcode, int sigerror);
  68.  
  69.  
  70. /* Make the thread described by SS take the signal described by signo
  71.    and sigcode.  */
  72. extern void __unixlib_internal_post_signal (struct unixlib_sigstate *ss,
  73.                     int signo, int sigcode, int error);
  74.  
  75. /* Set up SS to handle signal SIGNO by running HANDLER.
  76.    The handler is passed SIGNO and SIGCODE.  */
  77.  
  78. extern int __unixlib_setup_sighandler (struct unixlib_sigstate *ss,
  79.             __sighandler_t handler, int signo, int sigcode, int flags);
  80.  
  81. /* Function run for SIGINFO when its action is SIG_DFL and the current
  82.    process is the session leader.  */
  83.  
  84. extern void __unixlib_siginfo_handler (int);
  85.  
  86. /* Reserved for internal use by Unixlib. Preemptive signals can
  87.    be used to intercept a signal and handle it in a successful manner
  88.    which would then prevent an unnecessary signal being delivered.  */
  89.  
  90. struct unixlib_signal_preempt
  91.   {
  92.     /* The handler is called even for blocked signals. This function is
  93.        run in the sigal thread and should be as simple and robust as possible.
  94.        signo and sigcode would be passed to the normal handler.
  95.  
  96.        If the return value is SIG_DFL, normal signal processing continues.
  97.        If it is SIG_IGN, the signal is ignored.
  98.        Any other value is used in place of the normal handler.  */
  99.     sighandler_t (*handler) (int thread, int signo, int sigcode);
  100.     int first, last;        /* Range of sigcodes this handler wants.  */
  101.     struct unixlib_signal_preempt *next; /* Next handler on the chain. */
  102.   };
  103.  
  104. /* Pre-emptive signal handling.  Internal use only.  */
  105. extern int unixlib_preempt_signals (struct unixlib_signal_preempt *preempter,
  106.                      int signo, int first_code, int last_code,
  107.                      sighandler_t (*handler) (int, int, int));
  108.  
  109. extern int unixlib_unpreempt_signals (struct unixlib_signal_preempt *preempter,
  110.                                 int signo);
  111.  
  112. /* Initialise all the signals.  */
  113. extern void __unixlib_internal_signame_init (void);
  114.  
  115. /* Actual signal execution functions. Depends on whether we are
  116.    using sigstack, sigaltstack or not.  */
  117. extern void __unixlib_exec_sig (__sighandler_t, int);
  118. extern void __unixlib_exec_sigstack_bsd (void *sp, __sighandler_t, int);
  119. extern void __unixlib_exec_sigstack (void *sp, size_t size, __sighandler_t, int);
  120. extern void __unixlib_default_sigaction (struct unixlib_sigstate *);
  121.  
  122. /* Writes a friendly error message depending on whether the signal
  123.    produces a core dump or just terminates.  */
  124. extern int __write_corefile (int signo, int sigcode, int sigerror);
  125. extern void __write_termination (int signo, int sigcode, int sigerror);
  126.  
  127. /* Signal handler support functions.  */
  128.  
  129. extern void __h_sigill(void);    /*   undefined instruction handler */
  130. extern void __h_sigbus(void);    /*   address exception handler */
  131. extern void __h_sigsegv0(void); /*   prefetch abort handler */
  132. extern void __h_sigsegv1(void); /*   data abort handler */
  133.  
  134. extern void __h_sigfpe(void);    /*   FPE handler */
  135.  
  136. extern void __h_error(void);    /*   error handler */
  137. extern void __h_sigint(void);    /*   escape handler */
  138. extern void __h_event(void);    /*   event handler */
  139.  
  140. extern void __h_sigsys(void);    /*   unused SWI handler */
  141.  
  142. /* SIGALRM handler */
  143. extern void __h_sigalrm(void);
  144. extern void __h_sigalrm_init(void);
  145.  
  146. /* SIGVTALRM handler */
  147. extern void __h_sigvtalrm(void);
  148. extern void __h_sigvtalrm_init(void);
  149.  
  150. /* SIGPROF handler */
  151. extern void __h_sigprof(void);
  152. extern void __h_sigprof_init(void);
  153.  
  154. extern void __h_cback(void);    /*   CallBack handler */
  155. extern void __h_exit(void);    /*   exit handler - calls _exit() */
  156.  
  157. extern unsigned int __cbreg[16];    /* callback handler register buffer */
  158. extern char *__h_errbuf;        /* error handler string buffer */
  159.  
  160. /* alarm semaphores */
  161. extern int __h_sigprof_sema, __h_sigvtalrm_sema, __h_sigalrm_sema;
  162.  
  163. /* Wake a process up from sleeping.  */
  164. extern void sigwakeup (void);
  165.  
  166. /* Details for stack backtraces and core dumps.  */
  167.  
  168. /* Generate a stack backtrace, fp is the value of the
  169.    current frame pointer. */
  170. extern void __backtrace (unsigned int *fp);
  171.  
  172. /* Generate a core dump, from the current fp.  */
  173. extern void __core (void);
  174.  
  175. #endif    /* unixlib/signal.h */
  176.